package com.hema.auction.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hema.auction.R;
import com.hema.auction.bean.BidRecordInfo;
import com.hema.auction.utils.Utils;

import java.util.List;

/**
 * author by john
 */

public class BidRecordAdapter extends BaseQuickAdapter<BidRecordInfo, BaseViewHolder> {

    public BidRecordAdapter(@Nullable List<BidRecordInfo> data) {
        super(R.layout.layout_bid_record_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BidRecordInfo item) {
        TextView tvName = helper.getView(R.id.tv_name);
        if (helper.getLayoutPosition() == 0) {
            Drawable image = mContext.getResources().getDrawable(R.drawable.ic_phone_red);
            image.setBounds(0, 0, image.getMinimumWidth(), image.getMinimumHeight());
            tvName.setCompoundDrawables(image,null,null,null);
            helper.setTextColor(R.id.tv_name, mContext.getResources().getColor(R.color.colorPrimary));
            helper.setTextColor(R.id.tv_status, mContext.getResources().getColor(R.color.colorPrimary));
            helper.setTextColor(R.id.tv_location, mContext.getResources().getColor(R.color.colorPrimary));
            helper.setTextColor(R.id.tv_price, mContext.getResources().getColor(R.color.colorPrimary));
        } else {
            Drawable image = mContext.getResources().getDrawable(R.drawable.ic_phone_phone_black);
            image.setBounds(0, 0, image.getMinimumWidth(), image.getMinimumHeight());
            tvName.setCompoundDrawables(image,null,null,null);
            helper.setTextColor(R.id.tv_name, mContext.getResources().getColor(R.color.gray66));
            helper.setTextColor(R.id.tv_status, mContext.getResources().getColor(R.color.gray66));
            helper.setTextColor(R.id.tv_location, mContext.getResources().getColor(R.color.gray66));
            helper.setTextColor(R.id.tv_price, mContext.getResources().getColor(R.color.gray66));
        }
        helper.setText(R.id.tv_name, item.getUserName());
        if (helper.getLayoutPosition() == 0) {
            helper.setText(R.id.tv_status, "领先");
        } else {
            helper.setText(R.id.tv_status, "出局");
        }
//        helper.setText(R.id.tv_status, item.getStatus());
        helper.setText(R.id.tv_location, item.getCityName());
        helper.setText(R.id.tv_price, Utils.priceUnitFormat(mContext,item.getNowPrice()));
    }
}
